import {
    selectAll,
} from '@/api/orderItem'

const getDefaultState = () => {
    return {}
}

const state = getDefaultState()

const mutations = {
    RESET_STATE: (state) => {
        Object.assign(state, getDefaultState())
    }
}

const actions = {
    // use select all
    selectAll({
        commit
    }, orderItemInfo) {
        return new Promise((resolve, reject) => {
            const {
                obj,
                page,
                pageSize
            } = orderItemInfo
            selectAll({
                obj: obj,
                page: page,
                pageSize: pageSize
            }).then(response => {
                resolve(response.data)
            }).catch(error => {
                reject(error)
            })
        })
    },
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
